package com.example.workflow.controller;

import org.camunda.bpm.engine.IdentityService;
import org.camunda.bpm.engine.RuntimeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestCamundaController {

    @Autowired
    private IdentityService identityService;

    // 运行时
    @Autowired
    private RuntimeService runtimeService;

    @GetMapping("/start/{processKey}")
    public void test(@PathVariable("processKey") String processKey) {
        identityService.setAuthenticatedUserId("xiaoming");
        runtimeService.startProcessInstanceByKey(processKey);
    }

}
